package crypto

import (
	"crypto/md5"
	"fmt"
	"news_for_deepseek_interface/utils"
)

// HashPassword 使用salt对密码进行加密
func HashPassword(password, salt string) string {
	data := []byte(password + "|" + salt)
	return fmt.Sprintf("%x", md5.Sum(data))
}

// GenerateSalt 生成密码盐值
func GenerateSalt() string {
	return utils.GenerateString(16)
}

// VerifyPassword 验证密码
func VerifyPassword(inputPassword, hashedPassword, salt string) bool {
	return HashPassword(inputPassword, salt) == hashedPassword
}
